const cloud = require('wx-server-sdk')
cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV
})
const db = cloud.database()
exports.main = async (event, context) => {

          var caballero=event.caballero
          expressadd=event.expressadd
          image=event.image
          money=event.money
          pickupnum=event.pickupnum
          state=event.state
          time=event.time
          useradd=event.useradd
          _id=event._id//与快递表单表的id一致
          userid=event.userid//用户Id
          // _openid:res.data._openid,
          caballero_time=event.caballero_time//骑手确认取件的时间
          usersure_time=event.usersure_time//用户确认签收的时间
  try {
    return await db.collection('Dictionary').add({
      // data 字段表示需新增的 JSON 数据
      data: {
          caballero:caballero,
          expressadd:expressadd,
          image:image,
          money:money,
          pickupnum:pickupnum,
          state:state,
          time:time,
          useradd:useradd,
          _id:_id,
          userid:userid,
          // _openid:res.data._openid,
          caballero_time:caballero_time,
          usersure_time:usersure_time
      }
    })
  } catch(e) {
    console.error(e)
  }
}